Add phase labels and structured fields to config-load observability (#304)#380
Draft
leynos wants to merge 1 commit into
Draft
Add phase labels and structured fields to config-load observability (#304)#380leynos wants to merge 1 commit into
leynos wants to merge 1 commit into
Conversation
…304) Extend the config-load instrumentation from #303 so operators can attribute failures and latency to a specific startup phase and a coarse error cause. Metrics: `record_config_load_phase` now records the `diag_mode` and `merge` phases separately, adding a `phase` label to both `netsuke_config_load_total` (alongside `outcome`) and `netsuke_config_load_duration_seconds`. Diagnostic-mode resolution is infallible at the call boundary, so its phase is always `outcome=success`. Structured log fields: `handle_config_load_error` now annotates the `configuration load failed` event with `operation = "config_merge"` and an `error_category` derived from the `OrthoError` variant (`parse`/`io`/`validation`/`aggregate`/`other`). Document the per-phase labels, the structured-log-field contract, and the `error_category` mapping in `docs/developers-guide.md`. Add unit tests for the phase/outcome labels and the error classification.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
Reviewer's GuideAdds per-phase metrics labeling and structured error logging for configuration loading, splitting diagnostic-mode and merge phases and documenting the new observability contract. Sequence diagram for per-phase config-load metricssequenceDiagram
participant Main
participant resolve_configuration
participant cli_resolve_merged_diag_json as cli::resolve_merged_diag_json
participant cli_merge_with_config as cli::merge_with_config
participant record_config_load_phase
Main->>resolve_configuration: resolve_configuration(parsed_cli, matches)
activate resolve_configuration
resolve_configuration->>cli_resolve_merged_diag_json: resolve_merged_diag_json(parsed_cli, matches)
cli_resolve_merged_diag_json-->>resolve_configuration: mode_json_enabled
resolve_configuration->>record_config_load_phase: record_config_load_phase(PHASE_DIAG_MODE, diag_elapsed, true)
resolve_configuration->>cli_merge_with_config: merge_with_config(parsed_cli, matches)
cli_merge_with_config-->>resolve_configuration: merged_result
resolve_configuration->>record_config_load_phase: record_config_load_phase(PHASE_MERGE, merge_elapsed, merged_result.is_ok())
resolve_configuration-->>Main: (mode, merged_result)
deactivate resolve_configuration
Sequence diagram for structured error logging on config-load failuresequenceDiagram
participant Main
participant handle_config_load_error
participant error_category
participant tracing_error as tracing::error
Main->>handle_config_load_error: handle_config_load_error(err, mode)
activate handle_config_load_error
alt mode.is_json()
handle_config_load_error-->>Main: diagnostic_json::emit_or_fallback(...)
else human_output_mode
handle_config_load_error->>error_category: error_category(err)
error_category-->>handle_config_load_error: category
handle_config_load_error->>tracing_error: error!(error=%err, operation="config_merge", error_category=category, ...)
tracing_error-->>handle_config_load_error: event_recorded
handle_config_load_error-->>Main: ExitCode::FAILURE
end
deactivate handle_config_load_error
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #304
Extends the #303 config-load instrumentation with per-phase metric labels and structured error-log fields, the additional observability the review audit identified.
Stacked on #379 (#303); retargets to
mainautomatically once #379 merges.Changes
src/main.rs:record_config_load_phaserecords thediag_modeandmergephases separately, adding aphaselabel tonetsuke_config_load_total(withoutcome) andnetsuke_config_load_duration_seconds.handle_config_load_errorannotates theconfiguration load failedevent withoperation = "config_merge"and anerror_category(parse/io/validation/aggregate/other) derived from theOrthoErrorvariant via the newconst fn error_category.docs/developers-guide.md: per-phase label documentation plus a new Structured log fields subsection documenting theoperation/error_category/errorcontract and the JSON-mode exception.Testing
phase/outcomelabels on the counter and histogram and theerror_categoryclassification for representativeOrthoErrorvariants.Validation
make check-fmt/make markdownlint/make lint/make test— pass (37 suites)🤖 Generated with Claude Code
Summary by Sourcery
Add per-phase observability to configuration loading and enrich error logging for config-load failures.
New Features:
Enhancements:
Documentation:
Tests: